** @source JEEPS application and data functions
**
** @author Copyright (C) 1999 Alan Bleasby
-** @version 1.0
+** @version 1.0
** @modified Dec 28 1999 Alan Bleasby. First version
** @modified Copyright (C) 2004, 2005, 2006 Robert Lipe
** @@
-**
+**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
-**
+**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details.
-**
+**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
*/
typedef enum { UpperNo = 0, UpperYes = 1 } copycase;
-static
+static
void copy_char_array(UC **dst, char* src, int count, copycase mustupper)
{
UC *d = *dst;
do {
UC sc = *src++;
if (sc == 0) {
- while (count--)
+ while (count--)
*d++ = ' ';
break;
}
int32 GPS_Init(const char *port)
{
int32 ret;
-
- (void) GPS_Util_Little();
+
+ (void) GPS_Util_Little();
ret = GPS_A000(port);
if(ret<0) return ret;
gps_save_time = GPS_Command_Get_Time(port);
/*
- * Some units may be unable to return time, such as a C320 when in
+ * Some units may be unable to return time, such as a C320 when in
* charging mode. Only consider it fatal if the unit returns an error,
* not just absence of returning a time.
*/
gps_save_id = id;
gps_save_version = (double)((double)version/(double)100.);
- GPS_User("Unit:\t%s\nID:\t%d\nVersion:\t%.2f",
+ GPS_User("Unit:\t%s\nID:\t%d\nVersion:\t%.2f",
gps_save_string, gps_save_id, gps_save_version);
#if 0
gps_trk_type = -1;
gps_trk_hdr_type = -1;
gps_rte_link_type = -1;
-
+
gps_prx_waypt_transfer = -1;
gps_prx_waypt_type = -1;
gps_almanac_transfer = -1;
gps_almanac_type = -1;
gps_lap_transfer = -1;
gps_lap_type = -1;
-
+
if(!GPS_Device_Wait(fd))
{
GPS_Warning("A001 protocol not supported");
* reading until we incur a timeout.
* Worse still, the serial layer assumes a read timeout is a
* fatal error, while the USB layer (correctly) returns that error
- * to the caller. So we call GPS_Device_Wait which spins into
+ * to the caller. So we call GPS_Device_Wait which spins into
* a delay/select for the serial system and a NOP for USB.
*
* Worse _yet_, this is the one place in all of Garmin Protocolsville
/*
* If a 296 has previously been interrupted, it's going to
- * ignore the session request (grrrr) and continue to send
+ * ignore the session request (grrrr) and continue to send
* us left over packets. So if we see anything that isn't
* part of our A000 discovery cycle, reset the counter and
* continue to loop.
/* Make sure PVT is off as some GPS' have it on by default */
if(gps_pvt_transfer != -1)
GPS_A800_Off(port,&fd);
-
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
return 1;
}
-
+
/* @funcstatic GPS_A001 ************************************************
US tag;
US data;
US lasta=0;
-
+
gps_link_type = -1;
gps_device_command = -1;
gps_waypt_transfer = -1;
gps_almanac_type = -1;
gps_lap_transfer = -1;
gps_lap_type = -1;
-
+
entries = packet->n / 3;
p = packet->data;
-
+
for(i=0;i<entries;++i,p+=3)
{
tag = *p;
case 201:
gps_route_transfer = pA201;
break;
- case 300:
+ case 300:
gps_trk_transfer = pA300;
break;
case 301:
gps_waypt_type = data;
break;
- /*
+ /*
* Observered on Quest 3.0, 27xx, 27x, 29x.
*/
case 120:
}
}
-
+
else if(lasta<300)
{
gps_rte_link_type = data;
continue;
}
-
+
if(data<=110 && data>=100)
{
gps_rte_type = data;
if (data == 800)
gps_pvt_type = pD800;
/*
- * Stupid, undocumented Vista 3.60 D802 packets
+ * Stupid, undocumented Vista 3.60 D802 packets
else
GPS_Protocol_Error(tag,data);
*/
}
}
- GPS_User("\nLink_type %d Device_command %d\n",
+ GPS_User("\nLink_type %d Device_command %d\n",
gps_link_type, gps_device_command);
GPS_User("Waypoint: Transfer %d Type %d\n",
gps_waypt_transfer, gps_waypt_type);
GPS_Error("A100_Get: Cannot write packet");
return FRAMING_ERROR;
}
-
+
if(!GPS_Get_Ack(fd, &tra, &rec))
{
GPS_Error("A100_Get: No acknowledge");
GPS_Error("A100_GET: Waypoint entry number mismatch");
return FRAMING_ERROR;
}
-
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
GPS_Error("A101_Get: Cannot write packet");
return FRAMING_ERROR;
}
-
+
if(!GPS_Get_Ack(fd, &tra, &rec))
{
GPS_Error("A101_Get: No acknowledge");
int32 i;
p=s;
-
+
(*way)->prot = 100;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 101;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
p+=sizeof(float);
(*way)->smbl = *p;
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 102;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
(*way)->smbl = GPS_Util_Get_Short(p);
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 103;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
-
+
(*way)->smbl = *p++;
(*way)->dspl = *p;
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 104;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
-
+
(*way)->dst = GPS_Util_Get_Float(p);
p+=sizeof(float);
p+=sizeof(int16);
(*way)->dspl = *p;
-
+
return;
}
{
UC *p;
UC *q;
-
+
p=s;
-
+
(*way)->prot = 105;
(*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
q = (UC *) (*way)->wpt_ident;
while((*q++ = *p++));
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 106;
(*way)->wpt_class = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
(*way)->smbl = GPS_Util_Get_Short(p);
p+=sizeof(int16);
int32 i;
p=s;
-
+
(*way)->prot = 107;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
p+=sizeof(float);
(*way)->colour = *p++;
-
+
return;
}
{
UC *p;
UC *q;
-
+
int32 i;
p=s;
-
+
(*way)->prot = 108;
(*way)->wpt_class = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
(*way)->alt = GPS_Util_Get_Float(p);
p+=sizeof(float);
(*way)->dpth = GPS_Util_Get_Float(p);
q = (UC *) (*way)->ident;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->cmnt;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->facility;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->city;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->addr;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->cross_road;
while((*q++ = *p++));
-
+
return;
}
{
UC *p;
UC *q;
-
+
int32 i;
p=s;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
(*way)->alt = GPS_Util_Get_Float(p);
p+=sizeof(float);
(*way)->dpth = GPS_Util_Get_Float(p);
q = (UC *) (*way)->ident;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->cmnt;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->facility;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->city;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->addr;
while((*q++ = *p++));
-
+
q = (UC *) (*way)->cross_road;
while((*q++ = *p++));
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 150;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
for(i=0;i<2;++i) (*way)->cc[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
(*way)->alt = GPS_Util_Get_Short(p);
p+=sizeof(int16);
for(i=0;i<2;++i) (*way)->state[i] = *p++;
for(i=0;i<30;++i) (*way)->name[i] = *p++;
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 151;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
++p;
(*way)->wpt_class = *p;
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 152;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
++p;
(*way)->wpt_class = *p;
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 154;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
(*way)->wpt_class = *p++;
(*way)->smbl = GPS_Util_Get_Short(p);
-
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 155;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
(*way)->smbl = GPS_Util_Get_Short(p);
p+=sizeof(int16);
-
+
(*way)->dspl = *p;
-
+
return;
}
/*
* We'll cheat for now. We know there are no more than 16 categories
* as of this writing for no data type exposes more than 16 bits in the
- * bitmask of categories.
+ * bitmask of categories.
*/
char gps_categories[16][17];
-/*
+/*
* Read descriptor s into category number N;
*/
static
void GPS_D120_Get(int cat_num, char *s)
{
- /* we're guaranteed to have no more than 16 chars plus a
- * null terminator.
- *
+ /* we're guaranteed to have no more than 16 chars plus a
+ * null terminator.
+ *
* If the unit returned no string, the user has not configured one,
* so mimic the behaviour of the 276/296.
*/
if (*s) {
strncpy(gps_categories[cat_num], s, sizeof (gps_categories[0]));
} else {
- snprintf(gps_categories[cat_num], sizeof (gps_categories[0]),
+ snprintf(gps_categories[cat_num], sizeof (gps_categories[0]),
"Category %d", cat_num+1);
}
}
static void GPS_D100_Send(UC *data, GPS_PWay way, int32 *len)
{
UC *p;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
copy_char_array(&p, way->cmnt, 40, UpperYes);
*len = 58;
-
+
return;
}
static void GPS_D101_Send(UC *data, GPS_PWay way, int32 *len)
{
UC *p;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
*p = way->smbl;
*len = 63;
-
+
return;
}
static void GPS_D102_Send(UC *data, GPS_PWay way, int32 *len)
{
UC *p;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
p+= sizeof(float);
GPS_Util_Put_Short(p,(US) way->smbl);
-
+
*len = 64;
-
+
return;
}
static void GPS_D103_Send(UC *data, GPS_PWay way, int32 *len)
{
UC *p;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
*p++ = (UC) way->smbl;
*p = (UC) way->dspl;
-
+
*len = 60;
-
+
return;
}
static void GPS_D104_Send(UC *data, GPS_PWay way, int32 *len)
{
UC *p;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
*p = 3; /* display symbol with waypoint name */
*len = 65;
-
+
return;
}
{
UC *p;
UC *q;
-
+
p = data;
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lat));
*len = p-data;
-
+
return;
}
UC *p;
UC *q;
int32 i;
-
+
p = data;
-
+
*p++ = way->wpt_class;
for(i=0;i<13;++i) *p++ = way->subclass[i];
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lat));
while((*p++ = *q++));
*len = p-data;
-
+
return;
}
static void GPS_D107_Send(UC *data, GPS_PWay way, int32 *len)
{
UC *p;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
*p = way->colour;
*len = 65;
-
+
return;
}
{
UC *p;
UC *q;
-
+
int32 i;
-
+
p = data;
*p++ = way->wpt_class;
q = (UC *) way->cross_road;
i = XMIN(51, sizeof(way->cross_road));
while((*p++ = *q++) && i--);
-
+
*len = p-data;
-
+
return;
}
{
UC *p;
UC *q;
-
+
int32 i;
-
+
p = data;
*p++ = 1; /* data packet type; must be 1 for D109 and D110 */
*p++ = 0; // way->wpt_class;
-
+
*p++ = ((way->dspl & 3) << 5) | 0x1f; /* colour & display */
if (protoid == 109) { /* attr */
if(way->wpt_class == 7) way->wpt_class = 0;
*p++ = way->wpt_class;
-
+
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lat));
p+=sizeof(int32);
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon));
{
UC *p;
int32 i;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
-
+
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lat));
p+=sizeof(int32);
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon));
*p = way->wpt_class;
*len = 124;
-
+
return;
}
{
UC *p;
int32 i;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
-
+
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lat));
p+=sizeof(int32);
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon));
*p = way->wpt_class;
*len = 124;
-
+
return;
}
{
UC *p;
int32 i;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
-
+
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lat));
p+=sizeof(int32);
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon));
*p++ = way->wpt_class;
GPS_Util_Put_Short(p,(int16)way->smbl);
-
+
*len = 126;
-
+
return;
}
static void GPS_D155_Send(UC *data, GPS_PWay way, int32 *len)
{
UC *p;
-
+
p = data;
copy_char_array(&p, way->ident, 6, UpperYes);
-
+
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lat));
p+=sizeof(int32);
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon));
p+=sizeof(int16);
*p = way->dspl;
-
+
*len = 127;
-
+
return;
}
return gps_errno;
n = GPS_Util_Get_Short(rec->data);
-
+
if(n)
if(!((*way)=(GPS_PWay *)malloc(n*sizeof(GPS_PWay))))
{
if(!GPS_Packet_Read(fd, &rec))
return gps_errno;
-
+
if(!GPS_Send_Ack(fd, &tra, &rec))
return gps_errno;
GPS_Error("A200_GET: Route entry number mismatch");
return FRAMING_ERROR;
}
-
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
return gps_errno;
n = GPS_Util_Get_Short(rec->data);
-
+
if(n)
if(!((*way)=(GPS_PWay *)malloc(n*sizeof(GPS_PWay))))
{
if(!GPS_Packet_Read(fd, &rec))
return gps_errno;
-
+
if(!GPS_Send_Ack(fd, &tra, &rec))
return gps_errno;
GPS_Error("A200_GET: Route entry number mismatch");
return FRAMING_ERROR;
}
-
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
if(way[i]->isrte)
{
method = LINK_ID[gps_link_type].Pid_Rte_Hdr;
-
+
switch(gps_rte_hdr_type)
{
case pD200:
return FRAMING_ERROR;
}
}
-
+
GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Transfer_Wpt);
GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Xfer_Cmplt,
data,2);
if(way[i]->isrte)
{
method = LINK_ID[gps_link_type].Pid_Rte_Hdr;
-
+
switch(gps_rte_hdr_type)
{
case pD200:
else if(way[i]->islink)
{
method = LINK_ID[gps_link_type].Pid_Rte_Link_Data;
-
+
switch(gps_rte_link_type)
{
case pD210:
return FRAMING_ERROR;
}
}
-
+
GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Transfer_Wpt);
GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Xfer_Cmplt,
data,2);
(*way)->isrte = 1;
q = (UC *) (*way)->rte_ident;
while((*q++=*p++));
-
+
return;
}
UC *p;
UC *q;
int32 i;
-
+
p=s;
(*way)->rte_link_class = GPS_Util_Get_Short(p);
for(i=0;i<18;++i) (*way)->rte_link_subclass[i] = *p++;
q = (UC *) (*way)->rte_link_ident;
while((*q++=*p++));
-
+
return;
}
*data = way->rte_num;
*len = 1;
-
+
return;
}
static void GPS_D201_Send(UC *data, GPS_PWay way, int32 *len)
{
UC *p;
- int32 i;
-
+
p = data;
-
+
*p++ = way->rte_num;
- for(i=0;i<20;++i) *p++ = way->rte_cmnt[i];
+ copy_char_array(&p, way->rte_cmnt, 20, 1);
*len = 21;
-
+
return;
}
{
UC *p;
UC *q;
-
+
p = data;
q = (UC *) way->rte_ident;
-
+
while((*p++ = *q++));
*len = p-data;
-
+
return;
}
UC *p;
UC *q;
int32 i;
-
+
p = data;
GPS_Util_Put_Short(p,(US) way->rte_link_class);
while((*p++ = *q++));
*len = p-data;
-
+
return;
}
GPS_Warning("A300 protocol unsupported");
return GPS_UNSUPPORTED;
}
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
return gps_errno;
if(!GPS_Send_Ack(fd, &tra, &rec))
return gps_errno;
-
+
n = GPS_Util_Get_Short(rec->data);
GPS_Error("A300_GET: Track entry number mismatch");
return FRAMING_ERROR;
}
-
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
* The unit will not "finalize" a track unless the operator manually
* does it from the pushbutton panel OR until the device has gone through
* a 'get runs' cycle. Garmin's Training Center, of course, does this
- * because it actually uses that data. Here we just go through the
+ * because it actually uses that data. Here we just go through the
* mechanics of building and sending the requests and then throwing away
* all the data in order to finalize that.
*
* Hopefully, this won't be needed forever.
*/
-int
+int
drain_run_cmd(gpsdevh *fd)
{
GPS_PPacket tra;
GPS_Warning("A301 protocol unsupported");
return GPS_UNSUPPORTED;
}
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
return gps_errno;
if(!GPS_Send_Ack(fd, &tra, &rec))
return gps_errno;
-
+
n = GPS_Util_Get_Short(rec->data);
for(i=0;i<n;++i)
if(!((*trk)[i]=GPS_Track_New()))
return MEMORY_ERROR;
-
+
for(i=0;i<n;++i)
{
if(!GPS_Packet_Read(fd, &rec))
GPS_Error("A301_GET: Track entry number mismatch");
return FRAMING_ERROR;
}
-
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
if(gps_trk_transfer == -1)
return GPS_UNSUPPORTED;
-
+
/* Only those GPS' with L001 can send track data */
if(!LINK_ID[gps_link_type].Pid_Trk_Data)
{
GPS_Warning("A300 protocol unsupported");
return GPS_UNSUPPORTED;
}
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
return FRAMING_ERROR;
}
}
-
+
GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Transfer_Trk);
GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Xfer_Cmplt,
data,2);
int32 i;
int32 len;
UC method;
-
+
if(gps_trk_transfer == -1)
return GPS_UNSUPPORTED;
-
+
/* Only those GPS' with L001 can send track data */
if(!LINK_ID[gps_link_type].Pid_Trk_Data)
{
GPS_Warning("A301 protocol unsupported");
return GPS_UNSUPPORTED;
}
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
else
{
method = LINK_ID[gps_link_type].Pid_Trk_Data;
-
+
switch(gps_trk_type)
{
case pD300:
}
}
-
+
GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Transfer_Trk);
GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Xfer_Cmplt,
data,2);
GPS_PPacket tra;
GPS_PPacket rec;
int32 i;
-
+
if(!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New()))
return MEMORY_ERROR;
GPS_A300_Translate(rec->data, &trk[i]);
}
-
+
if(!GPS_Packet_Read(fd, &rec))
return gps_errno;
if(!GPS_Send_Ack(fd, &tra, &rec))
return gps_errno;
-
+
if(rec->type != LINK_ID[gps_link_type].Pid_Xfer_Cmplt)
{
{
UC *p;
uint32 t;
-
+
p=data;
-
+
(*trk)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
UC *p;
uint32 t;
double gps_temp;
-
+
p=data;
-
+
(*trk)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
uint32 raw_lat, raw_lon;
int lat_undefined, lon_undefined;
p=data;
-
- /* Latitude and longitude are sometimes invalid (0x7fffffff or
- * maybe 0xffffffff?) I guess this makes sense if the device is
- * reporting heart rate and time anyway. I presume that latitude
- * and longitude are defined or left undefined together?
+
+ /* Latitude and longitude are sometimes invalid (0x7fffffff or
+ * maybe 0xffffffff?) I guess this makes sense if the device is
+ * reporting heart rate and time anyway. I presume that latitude
+ * and longitude are defined or left undefined together?
*/
raw_lat = GPS_Util_Get_Int(p);
lat_undefined = !raw_lat || raw_lat==0x7fffffff || raw_lat==0xffffffff;
(*trk)->no_latlon = 1;
}
- if (lat_undefined != lon_undefined)
+ if (lat_undefined != lon_undefined)
GPS_Warning("GPS_D303b_Get: assumption (lat_undefined == lon_undefined) violated");
t = GPS_Util_Get_Uint(p);
(*trk)->Time = GPS_Math_Gtime_To_Utime((time_t)t);
p+=sizeof(uint32);
- /* When latitude and longitude are undefined, this field seems to be
+ /* When latitude and longitude are undefined, this field seems to be
* a constant on my receiver (51 59 04 69) */
(*trk)->alt = GPS_Util_Get_Float(p);
if (lat_undefined || lon_undefined) (*trk)->alt = 0.0f;
p+=sizeof(float);
- /* Heartrate is reported as 0 if there is no signal from
- * a heartrate monitor.
- * 305 and 304 are identical until now.
+ /* Heartrate is reported as 0 if there is no signal from
+ * a heartrate monitor.
+ * 305 and 304 are identical until now.
*/
switch (gps_trk_type) {
case pD304:
break;
}
- /* There doesn't seem to be a trk_seg bool, or at least I've not
- * observed it yet. One possibility is to start a new segment
- * each time latitude and longitude are undefined? (Ie data from
+ /* There doesn't seem to be a trk_seg bool, or at least I've not
+ * observed it yet. One possibility is to start a new segment
+ * each time latitude and longitude are undefined? (Ie data from
* the heartrate monitor but none from the GPS. */
(*trk)->tnew = 0;
{
UC *p;
UC *q;
-
+
p=s;
(*trk)->dspl = *p++;
{
UC *p;
short identifier;
-
+
p=s;
/* Forerunner */
p = data;
GPS_A300_Encode(p,trk);
p = data+12;
-
+
GPS_Util_Put_Float(p,trk->alt);
p+=sizeof(float);
GPS_Util_Put_Float(p,trk->dpth);
p+=sizeof(float);
*p = trk->tnew;
-
+
return;
}
p = data;
GPS_A300_Encode(p,trk);
p = data+12;
-
+
GPS_Util_Put_Float(p,trk->alt);
p+=sizeof(float);
-
+
GPS_Util_Put_Float(p, (const float) 1.0e25);
p+=sizeof(float);
{
UC *p;
UC *q;
-
+
p = data;
*p++ = trk->dspl;
*p++ = trk->colour;
-
+
q = (UC *) trk->trk_ident;
while((*p++ = *q++));
-
+
*len = p-data;
-
+
return;
}
{
UC *p;
uint32 t;
-
+
p=s;
-
+
(*trk)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(trk->lon));
p+=sizeof(int32);
-
+
GPS_Util_Put_Uint(p,GPS_Math_Utime_To_Gtime(trk->Time));
p+=sizeof(uint32);
if(!GPS_Packet_Read(fd, &rec))
return gps_errno;
-
+
if(!GPS_Send_Ack(fd, &tra, &rec))
return gps_errno;
GPS_Error("A400_GET: Prx waypoint entry number mismatch");
return FRAMING_ERROR;
}
-
-
+
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
GPS_PPacket rec;
int32 i;
int32 len;
-
+
if(gps_prx_waypt_transfer == -1)
return GPS_UNSUPPORTED;
return FRAMING_ERROR;
}
}
-
+
GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Transfer_Prx);
GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Xfer_Cmplt,
data,2);
int32 i;
p=s;
-
+
(*way)->prot = 400;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
(*way)->dst=GPS_Util_Get_Float(p);
-
-
+
+
return;
}
int32 i;
p=s;
-
+
(*way)->prot = 403;
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
p+=sizeof(int32);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
-
+
(*way)->smbl = *p++;
(*way)->dspl = *p++;
int32 i;
p=s;
-
+
(*way)->prot = 450;
(*way)->idx = GPS_Util_Get_Short(p);
p+=sizeof(int16);
-
+
for(i=0;i<6;++i) (*way)->ident[i] = *p++;
for(i=0;i<2;++i) (*way)->cc[i] = *p++;
(*way)->wpt_class = *p++;
(*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p));
p+=sizeof(int32);
-
+
(*way)->alt = GPS_Util_Get_Short(p);
p+=sizeof(int16);
for(i=0;i<40;++i) (*way)->cmnt[i] = *p++;
(*way)->dst=GPS_Util_Get_Float(p);
-
+
return;
}
{
UC *p;
int32 i;
-
+
p = data;
for(i=0;i<6;++i) *p++ = way->ident[i];
GPS_Util_Put_Float(p,way->dst);
*len = 62;
-
+
return;
}
{
UC *p;
int32 i;
-
+
p = data;
for(i=0;i<6;++i) *p++ = way->ident[i];
*p = way->dspl;
GPS_Util_Put_Float(p,way->dst);
-
+
*len = 64;
-
+
return;
}
for(i=0;i<6;++i) *p++ = way->ident[i];
for(i=0;i<2;++i) *p++ = way->cc[i];
*p++ = way->wpt_class;
-
+
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lat));
p+=sizeof(int32);
GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon));
for(i=0;i<40;++i) *p++ = way->cmnt[i];
GPS_Util_Put_Float(p,way->dst);
-
+
*len = 121;
if (gps_almanac_transfer == -1)
return GPS_UNSUPPORTED;
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
if(!GPS_Packet_Read(fd, &recpkt)) {
return gps_errno;
}
-
+
if(!GPS_Send_Ack(fd, &trapkt, &recpkt)) {
return gps_errno;
}
GPS_Error("A500_Get: Error transferring almanac");
return FRAMING_ERROR;
}
-
+
if(i != n) {
GPS_Error("A500_GET: Almanac entry number mismatch");
return FRAMING_ERROR;
}
-
+
GPS_Packet_Del(&trapkt);
GPS_Packet_Del(&recpkt);
int32 timesent;
int32 posnsent;
int32 ret;
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
return FRAMING_ERROR;
}
}
-
+
GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Transfer_Alm);
GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Xfer_Cmplt,
data,2);
ret = GPS_Rqst_Send_Time(fd,gps_save_time);
if(ret < 0) return ret;
}
-
+
if(!posnsent)
{
(*alm)->toa = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->af0 = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->af1 = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->e = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->sqrta = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->m0 = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->w = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->omg0 = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->odot = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*alm)->i = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
return;
}
*p = alm->svid;
GPS_A500_Encode(p+1,alm);
p[43] = alm->hlth;
-
+
return;
}
GPS_Util_Put_Short(p,alm->wn);
p+=sizeof(int16);
-
+
GPS_Util_Put_Float(p,alm->toa);
p+=sizeof(float);
GPS_PPacket tra;
GPS_PPacket rec;
time_t ret;
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
GPS_Error("A600_Get: Unknown data/time protocol");
return PROTOCOL_ERROR;
}
-
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
GPS_PPacket rec;
int32 posnsent=0;
int32 ret=0;
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
{
UC *p;
static struct tm ts;
-
+
p = packet->data;
ts.tm_mon = *p++ - 1;
*p++ = ts->tm_min;
*p = ts->tm_sec;
-
+
GPS_Make_Packet(packet, LINK_ID[gps_link_type].Pid_Date_Time_Data,
data,8);
gpsdevh *fd;
GPS_PPacket tra;
GPS_PPacket rec;
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
GPS_Error("A700_Get: Unknown position protocol");
return PROTOCOL_ERROR;
}
-
+
GPS_Packet_Del(&tra);
GPS_Packet_Del(&rec);
gpsdevh *fd;
GPS_PPacket tra;
GPS_PPacket rec;
-
+
if(!GPS_Device_On(port, &fd))
return gps_errno;
{
UC *p;
double t;
-
+
p = packet->data;
t = GPS_Util_Get_Double(p);
t = GPS_Util_Get_Double(p);
*lon = GPS_Math_Rad_To_Deg(t);
-
+
return;
}
lat = GPS_Math_Deg_To_Rad(lat);
lon = GPS_Math_Deg_To_Rad(lon);
-
+
p = data;
GPS_Util_Put_Double(p,lat);
p+=sizeof(double);
GPS_Util_Put_Double(p,lon);
-
+
GPS_Make_Packet(packet, LINK_ID[gps_link_type].Pid_Position_Data,
data,16);
static UC data[2];
GPS_PPacket tra;
GPS_PPacket rec;
-
+
if(!GPS_Device_On(port, fd))
return gps_errno;
static UC data[2];
GPS_PPacket tra;
GPS_PPacket rec;
-
+
if(!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New()))
return MEMORY_ERROR;
GPS_Error("A800_Off: Not acknowledged");
return FRAMING_ERROR;
}
-
+
GPS_Packet_Del(&rec);
GPS_Packet_Del(&tra);
if(!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New()))
return MEMORY_ERROR;
-
-
+
+
if(!GPS_Packet_Read(*fd, &rec)) {
GPS_Packet_Del(&rec);
GPS_Packet_Del(&tra);
return gps_errno;
}
-
+
if(!GPS_Send_Ack(*fd, &tra, &rec)) {
GPS_Packet_Del(&rec);
GPS_Packet_Del(&tra);
GPS_Packet_Del(&tra);
return 0;
}
-
+
switch(gps_pvt_type)
{
case pD800:
void GPS_D800_Get(GPS_PPacket packet, GPS_PPvt_Data *pvt)
{
UC *p;
-
+
p = packet->data;
(*pvt)->alt = GPS_Util_Get_Float(p);
(*pvt)->epv = GPS_Util_Get_Float(p);
p+=sizeof(float);
-
+
(*pvt)->fix = GPS_Util_Get_Short(p);
p+=sizeof(int16);
(*pvt)->lon = GPS_Math_Rad_To_Deg(GPS_Util_Get_Double(p));
p+=sizeof(double);
-
+
(*pvt)->east = GPS_Util_Get_Float(p);
p+=sizeof(float);
p+=sizeof(int16);
(*pvt)->wn_days = GPS_Util_Get_Int(p);
-
+
return;
}
GPS_Error("A906_GET: Lap entry number mismatch");
return FRAMING_ERROR;
}
-
+
GPS_Packet_Del(&trapkt);
GPS_Packet_Del(&recpkt);
void GPS_D1011b_Get(GPS_PLap *Lap, UC *p)
{
uint32 t;
-
+
/* Lap index (not in D906) */
switch(gps_lap_type) {
case pD906:
}
-/*
+/*
* It's unfortunate that these aren't constant and therefore switchable,
* but they really are runtime variable. Sigh.
*/
if (p == LT.Pid_Trk2_Hdr)
return "TRKHD2";
- if (p == GUSB_REQUEST_BULK)
+ if (p == GUSB_REQUEST_BULK)
return "REQBLK";
if (p == GUSB_SESSION_START)
return "SESREQ";